<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2008 XBRL International. All Rights Reserved. -->
<?xml-stylesheet type="text/xsl" href="../stylesheets/functionDefinition.xsl"?>
<function
  xmlns="http://xbrl.org/2008/function" 
  xmlns:reg="http://xbrl.org/2008/registry" 
  xmlns:xhtml="http://www.w3.org/1999/xhtml" 
  xmlns:xfi="http://www.xbrl.org/2008/function/instance"
  xmlns:xfie="http://www.xbrl.org/2008/function/instance/error"
  xmlns:xbrli="http://www.xbrl.org/2003/instance" 
  xmlns:xlink="http://www.w3.org/1999/xlink" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xsi:schemaLocation="
  http://xbrl.org/2008/registry ../schemas/registry.xsd
  http://xbrl.org/2008/function ../schemas/function.xsd
  ">

  <lastUpdated moment="2008-12-12T00:00:00" />

  <owners>
    <reg:owner id="herm">
       <reg:name>Herm Fischer</reg:name>
      <reg:affiliation>UBMatrix / Mark V Systems</reg:affiliation>
       <reg:email>fischer@markv.com</reg:email>
       <reg:assumedOwnership moment="2008-09-01T00:00:00" />
    </reg:owner>
  </owners>

  <summary>
    Returns a Xbrl Instance &lt;xbrli:xbrl&gt; element representing the
    specified Xbrl Instance.  
  </summary>

  <documentation>
      <xhtml:p>
    This function allows formula expressions to have access to multiple XBRL instances.
    It facilitates comparisons between
    the formula linkbase's usual target instance and one or more
    additional XBRL instance.  
      </xhtml:p>
      <xhtml:p>
    The instance that is loaded by this function
    has its nodes strongly typed according to its own Post Schema Validation
    Infoset.  Any of this instance's taxonomies which have same namespace as any prior-loaded
    XBRL instance's taxonomies may share the prior loaded taxonomies xsd's at the
    discretion of the implementors.  
      </xhtml:p>
      <xhtml:p>
        Regardless of whether this instance shares schema files with other loaded instances, its linkbases may be non
        intersecting with those of other instances and the DTS of this instance must be kept separate from the DTS
        of other instances (even if other instances DTSes have some same schema or linkbase files).  So a Q3 instance and Q2 
        instance may have same target namespaces but different linkbases.  The navigate-relationships and concept-labels
        functions are able to access relationships and resources appropriate to the loaded instance by the xbrli:xbrl
        object returned by this function, and if linkbases differ they remain distinct and accessible after loading.
      </xhtml:p>
      <xhtml:p>
    Repetitions of this function continue
    to return the identical result and XPath-identical nodes, it is expected that an efficient
    implementation will cache function results so that subsequent calls
    return the first-obtained result.  Using the same wording as XPath2 uses for its fn:doc(), two calls on the 
    xfi:xbrl-instance function return the same XBRL instance document node if the same URI Reference 
    (after resolution to an absolute URI Reference) is supplied to both calls. Thus, the following 
    XPath 2 expression (if it does not raise an error) will always be true: 
    xfi:xbrl-instance("foo.xml") is xfi:xbrl-instance("foo.xml").
      </xhtml:p>
      <xhtml:p>
        The nodes of the instance loaded by this function may be utilized in XPath2 expressions and as function
        call arguments within XPath2 expressions, and may be bound to generalVariables (but not factVariables).
        An XPath term referencing a node of this instance will only know about the DTS of this instance, e.g.,
        navigation among nodes of this instance is confined to nodes of this instance.  Functions that are node-aware
        such as node-name or xfi:concept-balance will use the node's parent XML document information or equivalent
        implementation information to know which of multiple DTSes in memory the function argument pertains to.
      </xhtml:p>
      <xhtml:p>
        Functions that are linkbase aware (such as xfi:navigate-relationships) lack an automatic way of
        determining which of multiple loaded instance DTSes they pertain to and thus have an (optional) 
        parameter of the instance node when it is desired to specify a DTS of an XBRL instance loaded by
        this function that is different than that of the target XBRL instance.
      </xhtml:p>
  </documentation>

  <signature name="xfi:xbrl-instance">

    <input name="href" type="xs:anyURI">
      <xhtml:p>
        The href that specifies the instance document to be loaded.
      </xhtml:p>
      <xhtml:p>
        If href is relative, then it is relative to the base URI of the target instance
        document, not relative to the formula linkbase.  This allows servers to keep
        their formula linkbases isolated from storage of server processes and their instance
        documents.
      </xhtml:p>
    </input>

    <output type="element(xbrli:xbrl)">
      <xhtml:p>
        Returns the xbrli:xbrl element of the href'ed instance, unless it can't be loaded, in which case an exception is raised.  The returned xbrli:xbrl element and all descendant nodes are PSVI typed according to the DTS of this loaded instance (not the DTS of the formula linkbase target instance).
      </xhtml:p>
      <xhtml:p>
           XPath 2 expressions with therms of this output element and its descendant nodes can intermix with terms of target instance nodes and nodes from any other xbrl-instance function loaded instances.  
      </xhtml:p>
      <xhtml:p>
           The DTS of this instance, including concept elements and their descendant nodes, arc relationships and their arc attributes, and linkbases with resources (such as labels) may be shared with other loaded instances if of the same target namespace identifier, or may be separate, at the discretion of the implementer.  Any access to such nodes will be PSVI typed (such as a weight attribute, of a calculation arc, accessed by the navigate-relationships function. 
      </xhtml:p>
    </output>
  </signature>

  <error code="xfie:unableToLoadXbrlInstance">
    <xhtml:p>
      This error MUST be thrown if the specified instance can't be loaded.
    </xhtml:p>
  </error>

  <conformanceTest xlink:type="simple" xlink:href="90601 xfi.xbrl-instance function testcase.xml"/>

  <revisions>
    <reg:revision on="2008-12-12T00:00:00" by="herm">
      <xhtml:p>
        Created the function definition.
      </xhtml:p>
    </reg:revision>
  </revisions>

</function>
